package com.jadeen.service.impl;


import com.jadeen.common.utils.DateUtils;
import com.jadeen.entity.domain.Favorite;
import com.jadeen.mapper.FavoriteMapper;
import com.jadeen.service.IFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户收藏Service业务层处理
 * 
 * @author jadeen
 * @date 2025-08-08
 */
@Service
public class FavoriteServiceImpl implements IFavoriteService
{
    @Autowired
    private FavoriteMapper favoriteMapper;

    /**
     * 查询用户收藏
     * 
     * @param favoriteId 用户收藏主键
     * @return 用户收藏
     */
    @Override
    public Favorite selectFavoriteByFavoriteId(Long favoriteId)
    {
        return favoriteMapper.selectFavoriteByFavoriteId(favoriteId);
    }

    /**
     * 查询用户收藏列表
     * 
     * @param favorite 用户收藏
     * @return 用户收藏
     */
    @Override
    public List<Favorite> selectFavoriteList(Favorite favorite)
    {
        return favoriteMapper.selectFavoriteList(favorite);
    }

    /**
     * 新增用户收藏
     * 
     * @param favorite 用户收藏
     * @return 结果
     */
    @Override
    public int insertFavorite(Favorite favorite)
    {
        favorite.setCreateTime(DateUtils.getNowDate());
        return favoriteMapper.insertFavorite(favorite);
    }

    /**
     * 修改用户收藏
     * 
     * @param favorite 用户收藏
     * @return 结果
     */
    @Override
    public int updateFavorite(Favorite favorite)
    {
        return favoriteMapper.updateFavorite(favorite);
    }

    /**
     * 批量删除用户收藏
     * 
     * @param favoriteIds 需要删除的用户收藏主键
     * @return 结果
     */
    @Override
    public int deleteFavoriteByFavoriteIds(Long[] favoriteIds)
    {
        return favoriteMapper.deleteFavoriteByFavoriteIds(favoriteIds);
    }

    /**
     * 删除用户收藏信息
     * 
     * @param favoriteId 用户收藏主键
     * @return 结果
     */
    @Override
    public int deleteFavoriteByFavoriteId(Long favoriteId)
    {
        return favoriteMapper.deleteFavoriteByFavoriteId(favoriteId);
    }
}
